#include "playerform.h"
#include "ui_playerform.h"

PlayerForm::PlayerForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PlayerForm)
{
    ui->setupUi(this);
}

PlayerForm::~PlayerForm()
{
    delete ui;
}
void PlayerForm::newsection()
{
    alive=true;
    looked=false;
    confi=50;
    risk=50;
    type=-1;
    {
        onescard[0]=0;
        onescard[1]=0;
        onescard[2]=0;
    }
    capital[0]=0;
    capital[1]=0;
    sub=0;
    subsub=0;
}
void PlayerForm::judge()
{
        if(onescard[1]>onescard[2])
        {
            int temp = onescard[2];
            onescard[2]=onescard[1];
            onescard[1]=temp;
        }
        if(onescard[0]>onescard[2])
        {
            int temp = onescard[2];
            onescard[2]=onescard[0];
            onescard[0]=temp;
        }
        if(onescard[0]>onescard[1])
        {
            int temp = onescard[0];
            onescard[0]=onescard[1];
            onescard[1]=temp;
        }
    if(onescard[0]+2==onescard[2]&&onescard[1]+1==onescard[2])
    {
        type=5;
        capital[0]=onescard[2]%13;
        capital[1]=onescard[2]/13;
    }
    else if(onescard[0]%13==0&&onescard[1]==onescard[0]+11&&onescard[2]==onescard[0]+12)
    {
        type=5;
        capital[0]=13;
        capital[1]=onescard[0]/13;
    }
    else if(onescard[0]%13==onescard[1]%13&&onescard[1]%13==onescard[2]%13)
    {
        type=4;
        if(onescard[0]%13==0)
        {
            capital[0]=13;
        }
        else
        {
            capital[0]=onescard[0]%13;
        }
    }
    else if((onescard[0]%13+2==onescard[2]%13)&&(onescard[1]%13+1==onescard[2]%13))
    {
        type=3;
        capital[0]=onescard[2]%13;
        capital[1]=onescard[2]/13;
    }
    else if(onescard[0]%13==0&&onescard[1]%13==11&&onescard[2]%13==12)
    {
        type=3;
        capital[0]=13;
        capital[1]=onescard[0]/13;
    }
    else if(onescard[0]/13==onescard[1]/13&&onescard[1]/13==onescard[2]/13)
    {
        type=2;
        if(onescard[0]%13==0)
        {
              capital[0]=13;
              sub=onescard[2]%13;
              subsub=onescard[1]%13;
        }
        else
        {
              capital[0]=onescard[2]%13;
              sub=onescard[1]%13;
              subsub=onescard[0]%13;
        }
        capital[1]=onescard[0]/13;
    }
    else if(onescard[0]%13==onescard[1]%13||onescard[0]%13==onescard[2]%13||onescard[1]%13==onescard[2]%13)
    {
        type=1;
        if(onescard[0]%13!=onescard[2]%13)
        {
            if(onescard[1]%13==onescard[2]%13)
            {
                if(onescard[1]%13==0)
                {
                    capital[0]=13;
                    sub=onescard[0]%13;
                }
                else
                {
                    capital[0]=onescard[1]%13;
                    sub=onescard[0]%13;
                }
                capital[1]=onescard[0]/13;
            }
            else
            {
                if(onescard[1]%13==0)
                {
                    capital[0]=13;
                    sub=onescard[2]%13;
                }
                else
                {
                    capital[0]=onescard[1]%13;
                    sub=onescard[2]%13;
                }
                capital[1]=onescard[2]%13;
            }
        }
        else
        {
            if(onescard[0]%13==0)
            {
                capital[0]=13;
                sub=onescard[1]%13;
            }
            else
            {
                capital[0]=onescard[1]%13;
                sub=onescard[1]%13;
            }
            capital[1]=onescard[2]/13;
        }

    }
    else
    {
        type=0;
        if(onescard[0]%13==0)
        {
            capital[0]=13;
            sub=onescard[2]%13;
            subsub=onescard[1]%13;
            capital[1]=onescard[0]/13;
        }
        else
        {
            capital[0]=onescard[2]%13;
            sub=onescard[1]%13;
            subsub=onescard[0]%13;
            capital[1]=onescard[2]%13;
        }
    }
}
void PlayerForm::defeated()
{
    ui->alivelabel->setText("出局");
}
void PlayerForm::setcoin()
{
    ui->lineEdit->setText(QString::number(coin));
}
void PlayerForm::setlooked()
{
    ui->label_4->setText("已看牌");
}
void PlayerForm::bwin()
{
    confi+=10;
}

